import Search from 'models/search';

import moment from 'moment';

export default class LogSearch extends Search {
  startTime = null;
  endTime = null;

  propertyList = ['startTime','endTime'];

  constructor(){
    super();
  }

  getObject(pagination) {
    let postData = {};
    let startTime = this.startTime;
    if (startTime !== null) {
      postData.startTime = moment(startTime).format('YYYY-MM-DD HH:mm:ss');
    }
    let endTime = this.endTime;
    if (endTime !== null) {
      postData.endTime = moment(endTime).format('YYYY-MM-DD HH:mm:ss');
    }

    if (pagination !== undefined) {
      let {
        limit,
        page
      } = pagination.getObject();
      postData.limit = limit;
      postData.page = page;
    }

    return postData;
  }
}